﻿using PlanningTasks.PlanTask;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PlanningTasks.App_Start
{
    public class App
    {
        public static int Counter { get; set; }

        public static void Init()
        {
            var random = new Random();

            var task = IntervalTask.CreateTask(() =>
            {
                if (IntervalTask.Current.ShuttingDown)
                {
                    //如果任务被重复执行
                    return;
                }
                //在这编写自己要执行的业务
                Counter++;
            });

            //时间间隔
            task.SetInterval(5000);
        }

        public static void End()
        {
            IntervalTask.Current.Dispose();
        }
    }
}